package com.situ.crm.controller.back;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.situ.crm.common.ServerResponse;
import com.situ.crm.entity.Permission;
import com.situ.crm.service.IPermissionService;

@Controller
@RequestMapping("/permission")
public class PermissionController {

	@Autowired
	private IPermissionService permissionService;
	//跳转到展示界面
	@RequestMapping("/getPage")
	public String getPage() {
		
		return "/permission/permission";
	}
	//分页查询
	@RequestMapping("/pageList")
	@ResponseBody
	public ServerResponse pageList(Integer page,Integer limit) {
		ServerResponse serverResponse = permissionService.pageList(page, limit); 
		
		return serverResponse;
	}
	//layui查找数据
	@RequestMapping("/selectAllPermissions")
	@ResponseBody
	public ServerResponse selectAllPermissions() {
		return permissionService.selectAllPermissions();
	}
	//跳转到添加界面
	@RequestMapping("/add")
	public String add () {
		
		return "/permission/permission_add";
	}
	//添加功能
	@RequestMapping("/insert")
	@ResponseBody
	public ServerResponse insert(Permission permission) {
		ServerResponse serverResponse = permissionService.insert(permission); 
		return serverResponse;
	}
}
